//
//  User.m
//  MarryAid
//
//  Created by hy007 on 13-1-10.
//  Copyright (c) 2013年 marry aid. All rights reserved.
//

#import "User.h"

static User *_currentUser;

@implementation User

@synthesize userID = _userID;
@synthesize sex = _sex;
@synthesize userName = _userName;
@synthesize avatar = _avatar;
@synthesize headImage = _headImage;

-(id)init{
	
	if(self = [super init]){

	}
	
	return self;
}

+ (User *)instance
{
    if (nil == _currentUser) {
		_currentUser = [[User alloc] init];
        _currentUser.userID = @"0";
        _currentUser.sex = 0;
        _currentUser.userName = @"";
        _currentUser.avatar = @"";
	}
    
	return _currentUser;
}


//基本用户信息
+(void)dicToUser:(NSDictionary *)dictionary
{
    if(_currentUser){
        if ([[dictionary objectForKey:@"userid"] length]>0)
        {
            _currentUser.userID = [dictionary objectForKey:@"userid"];
        }
        else
        {
            _currentUser.userID = @"";
        }
        
        if([[dictionary objectForKey:@"sex"] respondsToSelector:@selector(intValue)])
        {
            _currentUser.sex = [[dictionary objectForKey:@"sex"] intValue];
        }
        else
        {
            _currentUser.sex = -1;
        }
        
        if ([[dictionary objectForKey:@"username"] length]>0)
        {
            _currentUser.userName = [dictionary objectForKey:@"username"];
        }
        else
        {
            _currentUser.userName = @"";
        }
        if ([[dictionary objectForKey:@"avatar"] length]>0)
        {
            _currentUser.avatar = [dictionary objectForKey:@"avatar"];
        }
        else
        {
            _currentUser.avatar = @"";
        }
    }

}



@end
